import { ERR_OK } from './src/api/config'

var express = require('express')
var config = require('./vue.config.js')
var axios = require('axios')
var Qs = require ('qs')
var port = process.env.PORT || config.devServer.port

var app = express()

var apiRoutes = express.Router()

apiRoutes.get('/searchDoctor', function (req, res) {
  var url = 'http://192.168.50.250:8888/banner'
  axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
  axios.get(url, Qs.stringify(params)).then((response)=>{
    res.json(response.data)
  }).catch((e)=>{
    console.log(e)
  })
})

app.use('/api', apiRoutes)

app.use(express.static('./dist'))

module.exports = app.listen(port, function (err) {
  if (err) {
    console.log(err)
    return
  }
  console.log('Listening at http://localhost:' + port + '\n')
})
